import App from './App'

// #ifndef VUE3
import Vue from 'vue';
import uView from "uview-ui";
Vue.use(uView);
import messages from './locale/index'
import store from '@/utils/store'
let i18nConfig = {
  locale: uni.getLocale(),
  // locale: 'zh-Hans',
  // locale: 'en',
  messages
}

import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)
Vue.config.productionTip = false
App.mpType = 'app'
import {
	get,
	get2,
	post,
	baseUrl,
	next,
	next1,
} from '@/utils/request'
import {
	okShow,
	failShow, 
	// next,
	// next1,
	ToastOk,
	ToastFail,
	downLoad,
	daoChu,
	imgShow,
	savePhoto,
	formatNumberWithCommas,
	loading,
	newbaseUrl
} from '@/utils/_function.js'
Vue.prototype.$get = get
Vue.prototype.$get2 = get2
Vue.prototype.$post = post
Vue.prototype.$okShow = okShow
Vue.prototype.$failShow = failShow
Vue.prototype.$next = next
Vue.prototype.$next1 = next1
Vue.prototype.$ToastOk = ToastOk  
Vue.prototype.$ToastFail = ToastFail
Vue.prototype.$baseUrl = baseUrl
Vue.prototype.$newbaseUrl = newbaseUrl
Vue.prototype.$downLoad = downLoad
Vue.prototype.$imgShow = imgShow
Vue.prototype.$savePhoto = savePhoto,
Vue.prototype.$loading = loading
Vue.prototype.$formatNumberWithCommas = formatNumberWithCommas
Vue.prototype.$store = store;
// 手机打开文件方法
Vue.prototype.$daoChu = daoChu
// 时间格式化过滤器（全局的）
Vue.filter('date', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // yyyy-mm-dd hh:mm:ss
  // return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  return `${y}-${m}-${d}`
})
Vue.filter('formatter',function(time, pattern = "") {
	    var format = time.replace(/-/g, "/"); //把“-”，替换成‘/’
	      var date = new Date(format),
	        y = date.getFullYear(),
	        m = (date.getMonth()+1).toString().padStart(2, 0),
	        d = date.getDate().toString().padStart(2, 0),
	        h = date.getHours().toString().padStart(2, 0),
	        mi = date.getMinutes().toString().padStart(2, 0),
	        se = date.getSeconds().toString().padStart(2, 0);
	      if (pattern == "yyyy-mm-dd") {
	        return `${y}-${m}-${d}`;
	      } else {
	        return `${y}-${m}-${d} ${h}:${mi}:${se}`;
	      }
})
const app = new Vue({
	i18n,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
